package com.itjiange.rpc.easy.register;

import java.util.HashMap;
import java.util.Map;

/**
 * 本地服务注册器
 *
 * @author ItJianGe
 * @data 2024/9/6 11:17
 */
public class LocalRegister {

    /**
     * 服务注册器，用来存储服务名称，和基本信息
     */
    private static final Map<String, Class<?>> registerServiceMap = new HashMap<>();

    /**
     * 注册服务
     *
     * @param serviceName
     * @param serviceClass
     * @return
     */
    public static Class<?> registerService(String serviceName, Class<?> serviceClass) {
        return registerServiceMap.put(serviceName, serviceClass);
    }

    /**
     * 获取服务实例
     *
     * @param serviceName
     * @return
     */
    public static Class<?> getServiceClass(String serviceName) {
        return registerServiceMap.get(serviceName);
    }

    /**
     * 删除服务实例
     *
     * @param serviceName
     * @return
     */
    public static Class<?> removeService(String serviceName) {
        return registerServiceMap.remove(serviceName);
    }

}
